﻿/// <reference path="jquery-1.4.2.min.js" />
/// <reference path="CommonFunction.js" />

function GetDrug(objStockId) {
    var requestdata = JSON.stringify({ stockId: objStockId });
    $.ajax({
        type: "POST",
        url: "DrugServices.asmx/GetFromStock",
        data: requestdata,
        dataType: "json",
        contentType: "application/json; charset=utf-8",
        success: function(response) {
            var drug = response.d;           
            $("#UnitResult").text(drug.Unit);
            $("[id$=CostPriceResult]").val(CommaFormatted(drug.UnitPrice,0));
            $("[id$=TxtBatchLot]").val(drug.batchLot);
            $("[id$=txtExpDate]").val(drug.expDate);
            $("[id$=tbQuantity]").val(drug.quantity);
            $("[id$=HdStockQuantity]").val(drug.quantity);
        }
    });
}


function pageLoad() {
    $(function() {
        $('[id$=dataDrugId]').keypress(function(e) {
            var code = null;
            code = (e.keyCode ? e.keyCode : e.which);
            if (code == 13 || code == 9) {
                $("[id$=tbQuantity]").focus();
                $("[id$=tbQuantity]").select();
                return false;
            }
            return true;
        });
    });
}